﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using SocialShare.Web.Integrations;

public partial class forum_default : System.Web.UI.Page
{
    StrategyProxyUser user;
    private Int32 CatID
    {
        get
        {
            try
            {
               Int32 _catId= Convert.ToInt32(Page.RouteData.Values["catId"].ToString());
               if (_catId > 0)
               {
                   return _catId;
               }
               else
               {
                   return -1;
               }
            }
            catch
            {
                return -1;
            }
        }
    }

    public bool IsValid_USER
    {
        get
        {
            try
            {
                if (HttpContext.Current.Session["ValidUser"] != null)
                {
                    return Convert.ToBoolean(HttpContext.Current.Session["ValidUser"]);
                }
                else
                {
                    return false;
                }
            }
            catch
            {
                return false;
            }
        }
    }

    public String GetUserName(String userId)
    {
        if (user == null)
        {
            user = new StrategyProxyUser();
        }

        return user.GetUserName(userId);
       
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //if (!IsValid_USER) { Response.Redirect("~/unauthorized-access.aspx"); }
        }
        if (CatID != -1)
        {
            ObjectDataSource1.SelectMethod = "GetAllActiveForumMessagesByCategory";
            ObjectDataSource1.SelectCountMethod = "GetTotalCountActiveForumMessagesByCategory";
            ObjectDataSource1.SelectParameters["categoryId"].Direction = ParameterDirection.Input;
            ObjectDataSource1.SelectParameters["categoryId"].DefaultValue = CatID.ToString();
        }
        else
        {
            ObjectDataSource1.SelectMethod = "GetAllActiveForumMessages";
            
        }

    }
   
}